﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data;
using ASER.DataAccess.BaseDataAccess;
using ASER.DataEntity.Security;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ASER.DataAccess.Security
{
    public class DeptDataAccess : BaseDataAccess.BaseDataAccess<DeptartmentEntity>
    {
        public List<DeptartmentEntity> GetDepts()
        {
            string SqlText = "SELECT OrgCode,OrgName FROM  Sys_Organization ";

            List<DeptartmentEntity> Result = null;
            Database db = DatabaseFactory.CreateDatabase("Platform");
            using (DbCommand Command = db.GetSqlStringCommand(SqlText))
            {
                IDataReader Reader = db.ExecuteReader(Command);
                try
                {
                    Result = FillDataListGeneric(Reader);
                }
                finally
                {
                    Reader.Close();
                    Reader.Dispose();
                }
            }
            return Result;
        }
    }
}